﻿package flow {
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import caurina.transitions.Tweener;
	import flash.text.TextFormat;
	import fonts.UTMThanChienTranh;

	public class FlowInfo extends MovieClip {
		private function get title():MovieClip { return _title; }
		
		public function FlowInfo() {
			this.visible = false;
			this.alpha = 0;
			this.scaleX = 0;
			this.scaleY = 0;
			
			this.title.addEventListener(MouseEvent.MOUSE_DOWN, title_mousedown);
			stage.addEventListener(MouseEvent.MOUSE_UP, stage_mouseup);
		}
		
		private var dx,dy:Number = 0;
		private function title_mousedown(e:MouseEvent){
			this.dx = this.mouseX;
			this.dy = this.mouseY;
			stage.addEventListener(MouseEvent.MOUSE_MOVE, stage_mousemove);
		}
		
		private function stage_mouseup(e:MouseEvent){
			stage.removeEventListener(MouseEvent.MOUSE_MOVE, stage_mousemove);
		}
		
		private function stage_mousemove(e:MouseEvent){
			Tweener.addTween(this, {time:.75, x:stage.mouseX - this.dx, y:stage.mouseY - this.dy});
		}
		
		public function Show(){
			this.visible = true;
			Tweener.addTween(this, {time:.5, alpha:1, transition:"linear"});
			Tweener.addTween(this, {time:.5, scaleX:1, scaleY:1, transition:"easeOutQuint"});
		}
		public function Hide(){
			Tweener.addTween(this, {time:.5, alpha:0, transition:"easeOutQuint", onComplete:Hide_complete});
			Tweener.addTween(this, {time:.5, scaleX:0, scaleY:0, transition:"easeInOutQuint"});
		}
		
		private function Hide_complete(){
			this.visible = false;
		}
	}
}
